package sistema.controleVendas.persistencia;

import java.util.List;

import javax.persistence.EntityManager;
import sistema.controleVendas.entidades.Interesse;
public class GerenciarInteressePersistencia {
	EntityManager em = Conexao.contectar();

	public GerenciarInteressePersistencia() {
	}

	public void adicionarInteresse(Interesse interesse) {
		em.getTransaction().begin();
		em.persist(interesse);
		em.getTransaction().commit();
	}

	public List<Interesse> listarInteresse() {
		List<Interesse> interesses = em.createQuery(
				"select e from Interesse e").getResultList();
		return interesses;
	}
	public Interesse buscaInteresse(Interesse interesse){
		interesse = (Interesse) em.createQuery(
		"select e from Interesse e where e.id = :param").setParameter("param", interesse.getId()).getSingleResult();
		return interesse;
	}
}
